<div class="container-fluid">
    <div class="wrapper">
        <div class="panel" id="nav">
            <div class="panel-heading"><h3 class="panel-title">新建物流计划单</h3></div>
            <div class="panel-body">
                <div>
                    <?php
                        if (isset($newtransplan)&&$newtransplan!==false) {
                            echo "<span style='color:red;'>物流计划单：".$newtransplan." (平台计划单:".$cretedplans.")，创建成功!</span>";
                        }elseif (isset($newtransplan)&&$newtransplan===false) {
                            echo "<span style='color:red;'>平台计划单:".$_POST['platplans']."，状态不是待发货，请检查!</span>";
                        }
                    ?>
                    <form method="get" action="" id="form_search" >
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">站点</span>
                                <select class="chosen-select form-control" tabindex="-1" name="site_id"
                                        data-name-group="common" id='sitelist'>
                                    <option value="" class="empty-opt">-- 请选择 --</option>
                                    <volist name="sitelist" id="sl">
                                        <option value="{$key}"
                                        <?php if(isset($_GET['site_id'])&&$_GET['site_id']==$key){ echo ' selected';}?>>{$sl}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">承运商服务</span>
                                <select class="chosen-select form-control" tabindex="-1"
                                        data-name-group="common" name='carrier_service' id='carrier_service'>
                                    <option value=""
                                    <?php if(isset($_GET['carrier_service'])&&$_GET['carrier_service']==''){ echo ' selected';}?>>-- 请选择 --</option>
                                    <volist name='carrier_service' id='vo'>
                                        <option value="{$key}"
                                        <?php if(isset($_GET['carrier_service'])&&$_GET['carrier_service']==$key){ echo ' selected';}?>
                                        >{$vo}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-5  add-space">
                            <label>是否出口退税</label>
                            <label class="checkbox-inline">
                                <select class="form-control" tabindex="-1"
                                        data-name-group="common" name='taxrebate' id='taxrebate'>
                                    <option value="">-- 请选择 --</option>
                                    <option value="1"
                                    <?php if(isset($_GET['taxrebate'])&&$_GET['taxrebate']=="1"){ echo ' selected';}?>>是</option>
                                    <option value="0"
                                    <?php if(isset($_GET['taxrebate'])&&$_GET['taxrebate']=="0"){ echo ' selected';}?>>否</option>
                                </select>
                            </label>
                        </div>
                        <div class="col-sm-12 col-md-9  add-space">
                            <div class="input-group">
                                <span class="input-group-addon">日期选择</span>
                                <select name="datetype" class="form-control">
                                    <option value="claim_arrive_time"
                                    <?php if(isset($_GET['datetype'])&&$_GET['datetype']=='claim_arrive_time'){ echo ' selected';}?>
                                    >要求到货时间</option>
                                    <option value="create_time"
                                    <?php if(isset($_GET['datetype'])&&$_GET['datetype']=='create_time'){ echo ' selected';}?>>平台计划生成时间</option>
                                    <option value="package_print_time"
                                    <?php if(isset($_GET['datetype'])&&$_GET['datetype']=='package_print_time'){ echo ' selected';}?>
                                    >箱唛数据打印时间</option>
                                    <option value="package_upload_time"
                                    <?php if(isset($_GET['datetype'])&&$_GET['datetype']=='package_upload_time'){ echo ' selected';}?>
                                    >箱唛数据上传时间</option>
                                </select>
                                <span class="input-group-addon fix-border fix-padding"></span>
                                <input type="text" class="form-control form-date" name="start_time"
                                       value="<?php if(isset($_GET['start_time'])){ echo $_GET['start_time'];}?>">
                                <span class="input-group-addon fix-border fix-padding"><span
                                        class="icon-calendar"></span></span>
                                <input type="text" class="form-control form-date" name="end_time"
                                       value="<?php if(isset($_GET['end_time'])){ echo $_GET['end_time'];}?>">
                                <!-- <span class="input-group-addon fix-border fix-padding">&nbsp;<span class="text-danger">10</span>天&nbsp;</span> -->

                            </div>
                        </div>
                        <div class="col-sm-12 col-md-4  add-space">
                        <input type="submit" class="btn btn-sub btn-primary" value="查询">
                        <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#btn_import">物流交接单上传下载</button>
                    </div>
                    </form>
                </div>
                <div class="clearfix"></div>
                <div>
                    <table class="table table-hover" width="100%">
                        <thead>
                        <tr>
                            <th>
                                <input id="checkAll" type="checkbox"/>
                                <!-- <button onclick="chkall(document.plat_list,'all');">全选</button>
                                /
                                <button href="#bottom" onclick="chkall(document.plat_list,'none');">取消</button> -->
                            </th>
                            <th>序号</th>
                            <th>Shipmentid</th>
                            <th>状态</th>
                            <th>所属需求批次</th>
                            <th>账号名</th>
                            <th>站点</th>
                            <th>承运商服务</th>
                            <th>中转仓库名</th>
                            <th>包裹信息</th>
                            <th>亚马逊目的仓地址</th>
                            <th>备注</th>
                            <th><a style="cursor:pointer;">要求到货时间</a></th>
                            <!--<th>操作日志</th>-->
                        </tr>
                        </thead>
                        <form method="post" name="plat_list" id="plat_list">
                            <tbody id="pageData">
                            <volist name="platplans" id="vo">
                                <tr>
                                    <td><input type="checkbox" name="check" value="{$vo.id}"></td>
                                    <td>{$i}</td>
                                    <td>{$vo.shipmentid}</td>
                                    <td>{$vo.value}</td>
                                    <td>{$vo.batch_code}</td>
                                    <td>{$vo.account_name}</td>
                                    <td>{$vo.shorthand_code}</td>
                                    <td>{$carrier_service[$vo["carrier_service_id"]]}</td>
                                    <td>{$vo.name}</td>
                                    <td>
                                        包裹数:{$vo.total_package}<br>
                                        重量:{$vo.total_weight}<br>
                                        体积:{$vo.total_capacity}
                                    </td>
                                    <td>{$shiptoaddresses[$vo["ship_to_address_id"]]}</td>
                                    <td>{$vo.remark}</td>
                                    <td>{$vo.claim_arrive_time}</td>
                                    <!--<td>
                                         <button style="width:60px;" type="button" name="edit" class="btn btn-success" value="{$vo.id}">展开</button>
                                    </td>-->
                                </tr>
                            </volist>
                            <input type="hidden" name="platplans" id="platplans" value="">
                            </tbody>
                            <tfoot>
                            </tfoot>
                        <tr>
                            <td colspan="12">
                                <center><input type="button" name="createtransplan" id="createtransplan" class="btn btn-sub"
                                               value="创建物流计划单">
                                </center>
                            </td>
                        </tr>
                        </form>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="btn_import">
    <div class="modal-dialog">

        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
                        class="sr-only">关闭</span></button>
                <h4 class="modal-title">导入文件<span style="color: red">（导入请使用xlsx类型的）</span></h4>
            </div>
            <form action="__URL__/upload_site" method="post" enctype="multipart/form-data" id="upSku">
                <div class="modal-body form-horizontal">
                    <div class="alert alert-info top20" role="alert">
                        <p>模板下载: <a href="javascript:void(0)" id="download" >点击这里下载模板</a></p></div>

                    <div class="form-group"><label class="col-md-3 control-label required">上传文件</label>

                        <div class="col-md-4"><input name="file" class="form-control" data-val="true"
                                                     data-val-required="请选择[上传文件]!" id="File" type="file" value="">
                        </div>
                    </div>

                    <div class="form-group">
                        <button id="submit-button" type="submit" class="col-md-offset-3 col-md-1 btn btn-danger">上传
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            <button type="button" class="btn" data-dismiss="modal">取消</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/javascripts/admin/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $('select.chosen-select').chosen({
            no_results_text: '没有找到',    // 当检索时没有找到匹配项时显示的提示文本
            disable_search_threshold: 2, // 10 个以下的选择项则不显示检索框
            search_contains: true         // 从任意位置开始检索
        });
    });
    $(document).ready(function () {
        $("#checkAll").click(function () {
            if ($("#checkAll").attr("checked") == "checked") {
                $("input[name='check']").attr("checked", "checked");
            } else {
                $("input[name='check']").removeAttr("checked", "checked");
            }
        });
        var checked = [];
        $("#createtransplan").click(function () {
            $("input[name='check']:checked").each(function () {
                checked.push($(this).val());
            });
            if (checked.length == 0) {
                //alert(checked.length);
                alert('请选择要创建物流计划单的平台计划单!');
                return false;
            } else {
                if(confirm('确定要创建物流计划单？')){
                    $("#platplans").val(checked);
                    //alert(checked);
                    var url="{:U('Transportplan/editNewTrans')}?platid="+checked
                    layer.open({
                        type: 2,
                        title: '创建物流计划单',
                        shadeClose: false,
                        shade: 0.8,
                        area: ['50%', '70%'],
                        content: url
                    });
                }
            }
            ;
            /*var url = "{:U('Transportplan/createTransPlan')}?platorders=" + checked;
             window.open(url);*/
        });
    });
    function chkall(f, t) {
        els = f.elements;
        if (t == 'all') {
            chked = true;
        }
        if (t == 'none') {
            chked = false;
        }
        for (i = 0; i < els.length; i++) {
            if (els[i].type == 'checkbox') {
                els[i].checked = chked;
            }
        }
    }
    $("#download").click(function () {
        var fileName="物流交接单导入模板";
        var list=new Array(["站点"]);
        var list1= new Array(["US"]);
        window.location.href ="__URL__/tranDownload?"+"&fileName="+fileName+"&list="+list+"&list1="+list1;
    });
</script>